home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Information / WebSites / Wirenet / files / AutoNotify.lha / SendMail.br < prev   
Text File  |  1999-02-06  |  2KB  |  83 lines

  1. /*
  2. $VER: Sendmail 2.0 (17.12.98) Neil Bothwick
  3. A Thor script to create a Thor email event
  4. */
  5.  
  6. /* ;;; Initialise */
  7. options results
  8. if ~show('p', 'BBSREAD') then do
  9.     address command
  10.     'run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead'
  11.     'WaitForPort BBSREAD'
  12.     'WaitForPort BBSREAD'
  13.     end
  14. ;;;
  15. /* ;;; Read arguments */
  16. parse arg arguments
  17. template = 'SYSTEM/A,CONF/A,ADDRESS/A,NAME/K,SUBJECT/K,TEXT/K,CC/K,BCC/K,ATTACH/K'
  18. drop ARGS.
  19. ARGS.SUBJECT= ' '
  20. ARGS.TEXT = 'STDIN'
  21. address(BBSREAD)
  22. READARGS template ARGS CMDLINE arguments
  23. if RC = 5 then call ExitMsg('Usage: SendMail.br' template)
  24. ;;;
  25. /* ;;; Create message file */
  26. address(BBSREAD)
  27. drop SysInfo.
  28. GETBBSDATA bbsname '"'ARGS.SYSTEM'"' stem SysInfo
  29.  
  30. UNIQUEMSGFILE bbsname '"'ARGS.SYSTEM'"' stem MsgFile
  31. if ~open(out,MsgFile.NAME,'w') then call ExitMsg('Unable to create message file')
  32. if symbol('ARGS.CC') = VAR then call writeln(out,'cc:' ARGS.CC)
  33. if symbol('ARGS.BCC') = VAR then call writeln(out,'bcc:' ARGS.BCC)
  34.  
  35. /* Add contents of .header */
  36. if exists(SysInfo.BBSPATH||'.header') then do
  37.     if ~open(hdr,SysInfo.BBSPATH||'.header','r') then call ExitMsg('Could not open header file')
  38.     do until eof(hdr)
  39.         call writeln(out,readln(hdr))
  40.         end
  41.     call close(hdr)
  42.     end
  43. else if symbol('ARGS.CC') = VAR | symbol('ARGS.BCC') = VAR then call writeln(out,'')
  44.  
  45. /* Copy from text to message file */
  46. if ARGS.TEXT = 'STDIN' then do
  47.     do until eof('STDIN')
  48.         call writeln(out,compress(readln('STDIN'),'0d'x))       /* Strip superfluous CRs */
  49.         end
  50.     end
  51. else do
  52.     if ~open(text,ARGS.TEXT,'R') then call ExitMsg('Could not read message text file')
  53.     do until eof(text)
  54.         call writeln(out,compress(readln(text),'0d'x))          /* Strip superfluous CRs */
  55.         end
  56.     call close(text)
  57.     end
  58. call close(out)
  59. ;;;
  60. /* ;;; Create email event */
  61. drop EventData.
  62. EventData.TOADDR = ARGS.ADDRESS
  63. EventData.SUBJECT = ARGS.SUBJECT
  64. EventData.CONFERENCE = ARGS.CONF
  65. EventData.MSGFILE = MsgFile.FILEPART
  66. if symbol('ARGS.NAME') = VAR then EventData.TONAME = ARGS.NAME
  67. if symbol('ARGS.ATTACH') = VAR then EventData.LOCALFILE = ARGS.ATTACH
  68.  
  69. WRITEBREVENT bbsname '"'ARGS.SYSTEM'"' event 0 stem EventData
  70. if(rc ~= 0) then call ExitMsg(BBSREAD.LASTERROR)
  71. ;;;
  72.  
  73. exit
  74.  
  75. ExitMsg:
  76.     parse arg msg
  77.     if msg > '' then do
  78.         say;say msg;say
  79.         exit 5
  80.     else exit
  81.     return
  82.  
  83.